package com.codewsq.exer.syn3;


class SingletonThread extends Thread {

    @Override
    public void run() {
        Singleton instance = Singleton.getInstance();
        System.out.println(getName() + "实例化的对象：" + instance);
    }
}


public class SingletonTest {
    public static void main(String[] args) {
        SingletonThread s1 = new SingletonThread();
        SingletonThread s2 = new SingletonThread();
        SingletonThread s3 = new SingletonThread();
        SingletonThread s4 = new SingletonThread();
        SingletonThread s5 = new SingletonThread();

        s1.setName("线程1");
        s2.setName("线程2");
        s3.setName("线程3");
        s4.setName("线程4");
        s5.setName("线程5");

        s1.start();
        s2.start();
        s3.start();
        s4.start();
        s5.start();
    }
}
